#include "Speaker.h"
#include "SoundEngine.h"

using namespace sound;

Speaker::Speaker( Vec2 pos ) :
_pos( pos ),
_oldPos( pos ),
_vel( ) {
	SoundEngine::RegisterSpeaker( *this );
}

Speaker::~Speaker( ) {
	SoundEngine::UnregisterSpeaker( *this );
}

void Speaker::Update( float dt ) {
	_vel = ( _pos - _oldPos ) / dt;
	_oldPos = _pos;
	SoundEngine::Update( *this );
}

void Speaker::Play( const std::string& bufferName ) {
	SoundEngine::Play( *this, bufferName );
}

void Speaker::Stop( ) {
	SoundEngine::Stop( *this );
}
